package com.webex.ta.hydra.gui;

import com.webex.ta.hydra.core.FileService;
import com.webex.ta.hydra.gui.menu.HydraMenuBar;
import com.webex.ta.hydra.gui.menu.HydraToolBar;
import com.webex.ta.hydra.gui.table.HydraTable;
import com.webex.ta.hydra.gui.project.HydraProjectSuite;

/**
 * Created by Cisco WebEx.
 * User: vegaz
 * Date: 2010-8-20
 * Time: 10:03:40
 */
public class GuiPackage {
    private static GuiPackage guiPack;

    private HydraIdeFrame ideFrame;
    private HydraTable table;
    private HydraMenuBar menu;
    private HydraToolBar toolbar;
    private String testPlanFile;

    private GuiPackage() {}

    public static GuiPackage getInstance() {
        if (guiPack == null) {
            guiPack = new GuiPackage();
        }
        return guiPack;
    }

    public void setHydraTable(HydraTable table) {
        this.table = table;
    }

    public HydraTable getHydraTable() {
        return table;
    }

    public void setIdeFrame(HydraIdeFrame frame) {
        this.ideFrame = frame;
    }

    public HydraIdeFrame getIdeFrame() {
        return ideFrame;
    }

    public HydraProjectSuite getActiveProject() {
        if (ideFrame != null)
            return ideFrame.getActiveProject();
        return null;
    }

    public HydraMenuBar getMenu() {
        return menu;
    }

    public void setMenu(HydraMenuBar menu) {
        this.menu = menu;
    }

    public HydraToolBar getToolBar() {
        return toolbar;
    }

    public void setToolBar(HydraToolBar toolbar) {
        this.toolbar = toolbar;
    }

    public void setTestPlanFile(String file) {
        testPlanFile = file;
        FileService.getInstance().setBaseDir(testPlanFile);
        ideFrame.setExtendedFrameTitle(file);
//        ideFrame.projectFileLoaded(file);
    }

    public String getTestPlanFile() {
        return testPlanFile;
    }

    public void updateMenuAndToolBar() {
        if (toolbar != null)
            toolbar.update();
        if (menu != null)
            menu.updateEditMenu();
    }
}
